{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [],
   "source": [
    "# def transform(x):\n",
    "#     d1,d2 = str(x).split('.')\n",
    "#     return '2021'+d1 +d2\n",
    "\n",
    "# for i in range(1,24):\n",
    "#     if i < 10:\n",
    "#         i = '0'+str(i)\n",
    "#     df = pd.read_csv('./2021-12-{}/china_tend.csv'.format(str(i)),encoding='gbk',converters={'date':str})\n",
    "#     df['date'] = df['date'].apply(transform)\n",
    "#     df['date'] = pd.to_datetime(df['date'])\n",
    "#     df = df.sort_values('date', ascending=True)\n",
    "#     df = df.reindex(columns=['id','date','confirmed','unconfirmed','cured','died','curConfirmRelative','unconfirmedRelative','cureRelative','diedRelative','overseasInput','overseasInputRelative'])\n",
    "#     df['id'] = list(range(1,61))\n",
    "#     df.to_csv('./2021-12-{}/china_tend.csv'.format(str(i)),index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [],
   "source": [
    "# for i in range(10,25):\n",
    "#     if i < 10:\n",
    "#         i = '0'+str(i)\n",
    "#     df1 = pd.read_csv('./2021-11-{}/risk_areas.csv'.format(str(i)),encoding='utf-8')\n",
    "#     df2 = pd.read_csv('./2021-11-{}/change.csv'.format(str(i)),encoding='utf-8')\n",
    "#     df3=pd.concat([df1,df2])\n",
    "#     df3['no'] = list(range(1,len(df3)+1))\n",
    "#     df3 = df3.rename(columns = {'no':'id'})\n",
    "#     df3.to_csv('./2021-11-{}/change.csv'.format(str(i)),index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import datetime\n",
    "# import time\n",
    "# now = datetime.datetime.strptime('2021-11-09',\"%Y-%m-%d\")\n",
    "# for i in range(45):\n",
    "#     offset = datetime.timedelta(days=i)\n",
    "#     day = (now+offset).strftime('%Y-%m-%d')\n",
    "#     df1 = pd.read_csv('./{}/cities.csv'.format(day),encoding='utf-8')\n",
    "#     df1= df1.reindex(columns=['id','city','confirmed','died','crued','confirmedRelative','asymptomaticRelative','asymptomatic','nativeRelative','curConfirm'])\n",
    "#     df1['id'] = list(range(1,len(df1)+1))\n",
    "#     df1.to_csv('./{}/cities.csv'.format(day),index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 153,
   "metadata": {},
   "outputs": [],
   "source": [
    "# import datetime\n",
    "# import time\n",
    "# now = datetime.datetime.strptime('2021-11-09',\"%Y-%m-%d\")\n",
    "# for i in range(45):\n",
    "#     offset = datetime.timedelta(days=i)\n",
    "#     day = (now+offset).strftime('%Y-%m-%d')\n",
    "#     df1 = pd.read_csv('./{}/continent.csv'.format(day),encoding='utf-8')\n",
    "#     df1= df1.reindex(columns=['id','area','confirmed','confirmedRelative','crued','curConfirm','curedPercent','died','diedPercent'])\n",
    "#     df1['id'] = list(range(1,len(df1)+1))\n",
    "# #     print(df1.head())\n",
    "#     df1.to_csv('./{}/continent.csv'.format(day),index=False)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "import time\n",
    "now = datetime.datetime.strptime('2021-11-09',\"%Y-%m-%d\")\n",
    "for i in range(45):\n",
    "    offset = datetime.timedelta(days=i)\n",
    "    day = (now+offset).strftime('%Y-%m-%d')\n",
    "    df1 = pd.read_csv('./{}/local_hw.csv'.format(day),encoding='utf-8',converters={'date':str})\n",
    "    df1= df1.reindex(columns=['id','date','content','link'])\n",
    "    df1['id'] = list(range(1,len(df1)+1))\n",
    "#     print(df1.head())\n",
    "    df1.to_csv('./{}/local_hw.csv'.format(day),index=False)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "def transform(x):\n",
    "    return datetime.datetime.strptime(x, '%Y年%m月%d日').strftime(\"%Y-%m-%d\")\n",
    "\n",
    "now = datetime.datetime.strptime('2021-12-10',\"%Y-%m-%d\")\n",
    "for i in range(14):\n",
    "    offset = datetime.timedelta(days=i)\n",
    "    day = (now+offset).strftime('%Y-%m-%d')\n",
    "    df1 = pd.read_csv('./{}/local_hw.csv'.format(day),encoding='utf-8',converters={'date':str})\n",
    "    df1['date'] = df1['date'].apply(transform)\n",
    "    df1= df1.reindex(columns=['id','date','content','link'])\n",
    "    df1 = df1.sort_values('date', ascending=True)\n",
    "    df1['id'] = list(range(1,len(df1)+1))\n",
    "    df1.to_csv('./{}/local_hw.csv'.format(day),index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>date</th>\n",
       "      <th>confirmed</th>\n",
       "      <th>unconfirmed</th>\n",
       "      <th>cured</th>\n",
       "      <th>died</th>\n",
       "      <th>curConfirmRelative</th>\n",
       "      <th>unconfirmedRelative</th>\n",
       "      <th>cureRelative</th>\n",
       "      <th>diedRelative</th>\n",
       "      <th>overseasInput</th>\n",
       "      <th>overseasInputRelative</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2021-09-10</td>\n",
       "      <td>123423</td>\n",
       "      <td>3</td>\n",
       "      <td>115428</td>\n",
       "      <td>5687</td>\n",
       "      <td>37</td>\n",
       "      <td>2</td>\n",
       "      <td>54</td>\n",
       "      <td>1</td>\n",
       "      <td>8592</td>\n",
       "      <td>24</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2021-09-11</td>\n",
       "      <td>123478</td>\n",
       "      <td>2</td>\n",
       "      <td>115469</td>\n",
       "      <td>5687</td>\n",
       "      <td>55</td>\n",
       "      <td>0</td>\n",
       "      <td>41</td>\n",
       "      <td>0</td>\n",
       "      <td>8618</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2021-09-12</td>\n",
       "      <td>123544</td>\n",
       "      <td>3</td>\n",
       "      <td>115512</td>\n",
       "      <td>5687</td>\n",
       "      <td>66</td>\n",
       "      <td>0</td>\n",
       "      <td>43</td>\n",
       "      <td>0</td>\n",
       "      <td>8645</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2021-09-13</td>\n",
       "      <td>123642</td>\n",
       "      <td>0</td>\n",
       "      <td>115549</td>\n",
       "      <td>5688</td>\n",
       "      <td>98</td>\n",
       "      <td>0</td>\n",
       "      <td>37</td>\n",
       "      <td>1</td>\n",
       "      <td>8678</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2021-09-14</td>\n",
       "      <td>123722</td>\n",
       "      <td>1</td>\n",
       "      <td>115599</td>\n",
       "      <td>5688</td>\n",
       "      <td>80</td>\n",
       "      <td>1</td>\n",
       "      <td>50</td>\n",
       "      <td>0</td>\n",
       "      <td>8701</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id       date  confirmed  unconfirmed   cured  died  curConfirmRelative  \\\n",
       "0   1 2021-09-10     123423            3  115428  5687                  37   \n",
       "1   2 2021-09-11     123478            2  115469  5687                  55   \n",
       "2   3 2021-09-12     123544            3  115512  5687                  66   \n",
       "3   4 2021-09-13     123642            0  115549  5688                  98   \n",
       "4   5 2021-09-14     123722            1  115599  5688                  80   \n",
       "\n",
       "   unconfirmedRelative  cureRelative  diedRelative  overseasInput  \\\n",
       "0                    2            54             1           8592   \n",
       "1                    0            41             0           8618   \n",
       "2                    0            43             0           8645   \n",
       "3                    0            37             1           8678   \n",
       "4                    1            50             0           8701   \n",
       "\n",
       "   overseasInputRelative  \n",
       "0                     24  \n",
       "1                     26  \n",
       "2                     27  \n",
       "3                     33  \n",
       "4                     23  "
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
